<#include '/pages/taglib/core.ftl'>
<#include '/pages/taglib/common.ftl'>
<#include '/pages/taglib/export.ftl'>

<#assign hasPermission = fn.service('user').hasLinkPermission(fn.linkNoBase('/espirit/eap/pagelayout/page._add',true), false)>

<div style="clear: both;"></div>
<#assign targetAction = fn.linkModelNoBase(actionName, 'analyseImportFileColumns')>
<@form name='eapImportForm' action=targetAction>
	&nbsp;<div id="columnMappingCtn">
		<#assign importService = fn.service('espirit.eap.manager.eapImport')>
		<#assign importPropertyNames = importService.getImportPropertyNames(null)>
		<@importsetting name='genericImport' targetModelProperties=importPropertyNames/>
	</div>
	<div style="clear: both;"></div>
</@form>

<script>
$(function() {
	$("[name='model.file']", getActiveDom()).change(function() {
		var $form = $(this).closest('.jform');
		convertToForm($form);
		$form = $(this).closest('.jform');
		$form.attr('enctype', 'multipart/form-data');
		var url = $form.attr('action');
		var o = parseURL(url);
		o.method = 'analyseImportFileColumns';
		url = toURL(o);
		$form.ajaxSubmit({
			url: url,
			success: function(data) {
				$('#columnMappingCtn').html(data);
			}
		});
	});
});
</script>
